package com.nl.controller.xuyi.controller;

import com.github.pagehelper.PageInfo;
import com.nl.controller.common.model.BaseResult;
import com.nl.controller.common.model.Response;
import com.nl.controller.common.util.ResponseUtil;
import com.nl.controller.web.bean.SmsUsers;
import com.nl.controller.xuyi.bean.XuYiBlackUserInfo;
import com.nl.controller.xuyi.bean.contentcheck.ContentCheckInfo;
import com.nl.controller.xuyi.bean.contentcheck.ContentCheckTypeBo;
import com.nl.controller.xuyi.mapper.XuYiCheckMapper;
import com.nl.controller.xuyi.service.XuYiContentCheckService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * @desc 
 * @return null
 * @author ll
 * @date 2020/10/12 15:09
 */
@Slf4j
@RequestMapping("/xuYiContentCheck")
@RestController
public class XuYiContentCheckController {

	@Autowired
	XuYiContentCheckService xuYiContentCheckService;
	@Autowired
	XuYiCheckMapper xuYiContentCheckMapper;

	@PostMapping("/findCheckType")
	public BaseResult<List<ContentCheckTypeBo>> findCheckType(
			@RequestParam(value = "checkType",required =false) String checkType
	){
		log.info("XuYiContentCheckController findCheckType 查询审核类型列表 start request: "+ checkType);
		BaseResult<List<ContentCheckTypeBo>> result = xuYiContentCheckService.findCheckType(checkType);
		log.info("XuYiContentCheckController findCheckType 查询审核类型列表 end response: "+ checkType);
		return result;
	}

	@PostMapping("/findCheckList")
	public Response findCheckList(
			@RequestParam(value = "page", required = true) int page,
			@RequestParam(value = "limit", required = true) int limit,
			@RequestParam(value = "checkType",required =false) String checkType,
			@RequestParam(value = "checkState",required =false) String checkState,
			@RequestParam Map<String, Object> paramMap
	){
		log.info("XuYiContentCheckController findCheckList 查询审核类型列表 start request: "+ paramMap.toString());
		PageInfo<ContentCheckInfo> pageInfo = xuYiContentCheckService.findCheckList(page,limit,checkType,checkState);
		log.info("XuYiContentCheckController findCheckList 查询审核类型列表 end response: "+ pageInfo.toString());
		return ResponseUtil.sucess(pageInfo.getList(), pageInfo.getTotal());
	}

	@PostMapping("/findCheckDetail")
	public BaseResult<ContentCheckInfo> findCheckDetail(
			@RequestBody ContentCheckInfo contentCheckInfo
	){
		log.info("XuYiContentCheckController findCheckList 查询审核信息详情 start request: "+ contentCheckInfo.toString());
		BaseResult<ContentCheckInfo> checkDetail = xuYiContentCheckService.findCheckDetail(contentCheckInfo);
		log.info("XuYiContentCheckController findCheckList 查询审核信息详情 end response: "+ checkDetail.toString());
		return checkDetail;
	}

	@PostMapping("/updateCheckInfo")
	public BaseResult updateCheckInfo(
			@RequestBody ContentCheckInfo contentCheckInfo,
			HttpSession session
	){
		SmsUsers user = (SmsUsers) session.getAttribute("user");
		contentCheckInfo.setCheckOperatorTel(user.getMsisdn());
		log.info("XuYiContentCheckController updateCheckInfo 更新短信审核表审核状态 start request: "+ contentCheckInfo.toString());
		BaseResult checkDetail = xuYiContentCheckService.updateCheckInfo(contentCheckInfo);
		log.info("XuYiContentCheckController updateCheckInfo 更新短信审核表审核状态 end response: "+ checkDetail.toString());
		return checkDetail;
	}

	@PostMapping("/dealCheckResult")
	public BaseResult dealCheckResult(
			@RequestParam(value = "checkId",required = false) String checkId,
			HttpSession session,@RequestParam Map<String, Object> paramMap
	){
		log.info("XuYiContentCheckController dealCheckResult  处理短信内容审核通过 start request: "+ paramMap.toString());
		BaseResult checkDetail = xuYiContentCheckService.dealCheckResult(checkId);
		log.info("XuYiContentCheckController dealCheckResult 处理短信内容审核通过 end response: "+ checkDetail.toString());
		return checkDetail;
	}

    
}
